package app

import (
	"fmt"

	"github.com/spf13/pflag"
)

const (
	flagHelp          = "help"
	flagHelpShorthand = "H"
)

// func helpCommand(name string) *cobra.Command {
// 	return &cobra.Command{
// 		Use:   "help [command]",
// 		Short: "Help about any command.",
// 		Long:  "use " + name + " help [path to command] for full details",
// 		Run: func(c *cobra.Command, args []string) { // 这是一段模板代码，无需改动
// 			cmd, _, e := c.Root().Find(args)
// 			if cmd == nil || e != nil {
// 				c.Printf("Unknown help topic %#q\n", args)
// 				_ = c.Root().Usage()
// 			} else {
// 				cmd.InitDefaultHelpFlag()
// 				_ = cmd.Help()
// 			}
// 		},
// 	}
// }

// 应用顶层的 help
func AddHelpFlag(name string, fs *pflag.FlagSet) {
	pflag.BoolP(flagHelp, flagHelpShorthand, false, fmt.Sprintf("Help for %s.", name))
	fs.AddFlag(pflag.Lookup(flagHelp))
}
